package com.woniuxy.project.campus.canteen.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.project.campus.canteen.model.Shops;
import com.woniuxy.project.campus.canteen.param.ApplyParam;
import com.woniuxy.project.campus.canteen.service.ShopAdminService;
import com.woniuxy.project.campus.canteen.service.ShopsService;
import com.woniuxy.project.campus.canteenModelform.AdminApproval;
import com.woniuxy.project.campus.canteenModelform.ApplyForm;
import com.woniuxy.project.campus.util.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 猫将军
 * @since 2025年02月17日
 */
@RestController
@RequestMapping("/shopAdmin")
public class ShopAdminController {

@Resource
    private ShopAdminService shopAdminService;
@Resource
    private ShopsService shopsService;

    @ApiOperation(value = "商户申请")
        //商户申请
    @RequestMapping("/apply")
    public Result apply(ApplyForm applyForm) throws Exception {
        ApplyParam Param = BeanUtil.toBean(applyForm, ApplyParam.class);
        shopAdminService.apply(Param);
        return Result.success(null);
    }

    //管理员审批入驻申请
    @ApiOperation(value = "管理员审批入驻申请", notes = "传入用户id，获取用户入住申请信息")
    @PostMapping("/adminApproval")
    public Result adminApproval(@RequestBody AdminApproval bean) throws Exception {
        shopAdminService.adminApproval(bean);
        return Result.success(null);
    }



    @ApiOperation(value = "商户查询自己的店铺", notes = "传入用户id获取默认店铺信息")
    @PostMapping("/getShopInfo")
    public Result getShopInfo(@RequestHeader("token") String token) throws Exception {
       Shops shops = shopsService.getShopInfo(token);
        return Result.success(shops);
    }
    //用户修改店铺信息




}

